{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "from tqdm import tqdm\n",
    "import scipy.sparse as sp\n",
    "from copy import deepcopy\n",
    "import warnings \n",
    "import os\n",
    "from sklearn.model_selection import KFold\n",
    "import json\n",
    "warnings.filterwarnings(\"ignore\") \n",
    "import random\n",
    "random.seed(1234)\n",
    "np.random.seed(1234)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": [
    "def obtain_data(task, isbalance, balance):\n",
    "    \n",
    "    pwd = r'../data/0_data/'\n",
    "    if isbalance:\n",
    "        node_feature_label = pd.read_csv(pwd + 'node_feature_label.csv', index_col = 0)\n",
    "    \n",
    "    train_test_id_idx = np.load(r'../data/task_' + task + balance + '__testlabel0_knn_edge_train_test_index_all.npz', allow_pickle = True)\n",
    "    train_index_all = train_test_id_idx['train_index_all']\n",
    "    test_index_all = train_test_id_idx['test_index_all']\n",
    "    \n",
    "    num_node = node_feature_label.shape[0]\n",
    "    node_feat = node_feature_label.iloc[:, 3:]\n",
    "    label = node_feature_label['label']\n",
    "\n",
    "    gene_ids = list(set(node_feature_label['gene_idx']))\n",
    "    peco_ids = list(set(node_feature_label['peco_idx']))\n",
    "    random.shuffle(gene_ids)\n",
    "    random.shuffle(peco_ids)\n",
    "    print('# gene = {} | peco = {}'.format(len(gene_ids), len(peco_ids)))\n",
    "    \n",
    "    gene_test_num = int(len(gene_ids) / 5)\n",
    "    peco_test_num = int(len(peco_ids) / 5)\n",
    "    print('# Test: gene = {} | peco = {}'.format(gene_test_num, peco_test_num))\n",
    "    \n",
    "    return node_feature_label, num_node, node_feat, label, gene_ids, peco_ids, train_index_all, test_index_all"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": [
    "def generate_graphsaint_data(task, train_index_all, test_index_all, node_feat, n_neigh, label, num_node, balance):\n",
    "\n",
    "    fold = 0\n",
    "    for train_idx, test_idx in zip(train_index_all, test_index_all): #train_index与test_index为下标\n",
    "        # read knn_graph\n",
    "        pwd = r'../data/0_data/'\n",
    "        knn_graph_file = 'task_' + task + balance + '__testlabel0_knn' + str(n_neigh) + 'neighbors_edge__fold' + str(fold) + '.npz'\n",
    "        knn_neighbors_graph = sp.load_npz(pwd + knn_graph_file)\n",
    "\n",
    "\n",
    "        edge_src_dst = knn_neighbors_graph.nonzero()\n",
    "        #print(edge_src_dst)\n",
    "        \n",
    "        # save dir\n",
    "        save_dir = r'../gene_peco_data_/task_' + task + balance + '__testlabel0_' + str(n_neigh) + 'knn_edge_fold' + str(fold) + '/'\n",
    "\n",
    "        try:\n",
    "            os.mkdir(save_dir)\n",
    "        except OSError as error:\n",
    "            print(error, save_dir)\n",
    "        feats = np.array(node_feat,dtype='float32')\n",
    "        np.save(save_dir + 'feats.npy', feats)\n",
    "        \n",
    "        try:\n",
    "            train_idx, test_idx = train_idx.tolist(), test_idx.tolist()\n",
    "        except:\n",
    "            train_idx, test_idx = train_idx, test_idx\n",
    "            \n",
    "        # role.json\n",
    "        role = dict()\n",
    "        role['tr'] = train_idx\n",
    "        role['va'] = test_idx\n",
    "        role['te'] = test_idx\n",
    "        with open(save_dir + 'role.json','w') as f:\n",
    "            json.dump(role, f)\n",
    "\n",
    "        # class_map.json\n",
    "        y = np.array(label)\n",
    "        class_map = dict()\n",
    "        for i in range(num_node):\n",
    "            class_map[str(i)] = y[i].tolist()\n",
    "        with open(save_dir + 'class_map.json', 'w') as f:\n",
    "            json.dump(class_map, f)\n",
    "\n",
    "        # adj_*.npz\n",
    "        train_idx_set = set(train_idx)\n",
    "        test_idx_set = set(test_idx)\n",
    "        \n",
    "        row_full, col_full = edge_src_dst[0], edge_src_dst[1]\n",
    "        \n",
    "        row_train = []\n",
    "        col_train = []\n",
    "        row_val = []\n",
    "        col_val = []\n",
    "        for i in tqdm(range(row_full.shape[0])):\n",
    "            if row_full[i] in train_idx_set and col_full[i] in train_idx_set:\n",
    "                row_train.append(row_full[i])\n",
    "                col_train.append(col_full[i])\n",
    "            if row_full[i] in test_idx_set and col_full[i] in test_idx_set:\n",
    "                row_val.append(row_full[i])\n",
    "                col_val.append(col_full[i])\n",
    "\n",
    "        row_train = np.array(row_train)\n",
    "        col_train = np.array(col_train)\n",
    "        row_val = np.array(row_val)\n",
    "        col_val = np.array(col_val)\n",
    "        dtype = np.bool\n",
    "\n",
    "        adj_full = sp.coo_matrix(\n",
    "            (\n",
    "                np.ones(row_full.shape[0], dtype=dtype),\n",
    "                (row_full, col_full),\n",
    "            ),\n",
    "            shape=(num_node, num_node)\n",
    "        ).tocsr()\n",
    "\n",
    "        adj_train = sp.coo_matrix(\n",
    "            (\n",
    "                np.ones(row_train.shape[0], dtype=dtype),\n",
    "                (row_train, col_train),\n",
    "            ),\n",
    "            shape=(num_node, num_node)\n",
    "        ).tocsr()\n",
    "\n",
    "        adj_val = sp.coo_matrix(\n",
    "            (\n",
    "                np.ones(row_val.shape[0], dtype=dtype),\n",
    "                (row_val, col_val),\n",
    "            ),\n",
    "            shape=(num_node, num_node)\n",
    "        ).tocsr()\n",
    "\n",
    "        print('adj_full  num edges:', adj_full.nnz)\n",
    "        print('adj_val   num edges:', adj_val.nnz)\n",
    "        print('adj_train num edges:', adj_train.nnz)\n",
    "        sp.save_npz(save_dir + 'adj_full.npz', adj_full)\n",
    "        sp.save_npz(save_dir + 'adj_train.npz', adj_train)\n",
    "        sp.save_npz(save_dir + 'adj_val.npz', adj_val) # adj_val not used in GraphSAINT source code\n",
    "\n",
    "        fold += 1\n",
    "    \n",
    "    print('--Complete--', fold)\n",
    "    return feats, role, class_map, adj_full, adj_train, adj_val, edge_src_dst"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": [
    "def run(task, isbalance):\n",
    "    \n",
    "    if isbalance:\n",
    "        balance = ''\n",
    "    else:\n",
    "        balance = '__nobalance'\n",
    "    for n_neigh in [1, 3, 5, 7, 10, 15]:\n",
    "\n",
    "        node_feature_label, num_node, node_feat, label, gene_ids, peco_ids, train_index_all, test_index_all = obtain_data(task, \n",
    "                                                                                                                              isbalance,\n",
    "                                                                                                                              balance)\n",
    "        feats, role, class_map, adj_full, adj_train, adj_val, edge_src_dst = generate_graphsaint_data(task, train_index_all, test_index_all, node_feat, n_neigh,\n",
    "                                                                                        label, \n",
    "                                                                                        num_node, \n",
    "                                                                                        balance)\n",
    "    return node_feature_label, num_node, node_feat, label, gene_ids, peco_ids, train_index_all, test_index_all, \\\n",
    "    feats, role, class_map, adj_full, adj_train, adj_val, edge_src_dst"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "pycharm": {
     "name": "#%% md\n"
    }
   },
   "source": [
    "# RUN balance"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "# gene = 11177 | peco = 24\n",
      "# Test: gene = 2235 | peco = 4\n",
      "[WinError 183] 当文件已存在时，无法创建该文件。: 'E:/MDA-GCNFTG-main/gene_peco_data_/task_Tpe__testlabel0_1knn_edge_fold0/' E:/MDA-GCNFTG-main/gene_peco_data_/task_Tpe__testlabel0_1knn_edge_fold0/\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 47116/47116 [00:00<00:00, 724898.13it/s]\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "adj_full  num edges: 47116\n",
      "adj_val   num edges: 4866\n",
      "adj_train num edges: 40006\n",
      "[WinError 183] 当文件已存在时，无法创建该文件。: 'E:/MDA-GCNFTG-main/gene_peco_data_/task_Tpe__testlabel0_1knn_edge_fold1/' E:/MDA-GCNFTG-main/gene_peco_data_/task_Tpe__testlabel0_1knn_edge_fold1/\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 47116/47116 [00:00<00:00, 628222.92it/s]\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "adj_full  num edges: 47116\n",
      "adj_val   num edges: 3712\n",
      "adj_train num edges: 40832\n",
      "[WinError 183] 当文件已存在时，无法创建该文件。: 'E:/MDA-GCNFTG-main/gene_peco_data_/task_Tpe__testlabel0_1knn_edge_fold2/' E:/MDA-GCNFTG-main/gene_peco_data_/task_Tpe__testlabel0_1knn_edge_fold2/\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 47116/47116 [00:00<00:00, 692893.70it/s]\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "adj_full  num edges: 47116\n",
      "adj_val   num edges: 4164\n",
      "adj_train num edges: 40715\n",
      "[WinError 183] 当文件已存在时，无法创建该文件。: 'E:/MDA-GCNFTG-main/gene_peco_data_/task_Tpe__testlabel0_1knn_edge_fold3/' E:/MDA-GCNFTG-main/gene_peco_data_/task_Tpe__testlabel0_1knn_edge_fold3/\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 47116/47116 [00:00<00:00, 692918.00it/s]\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "adj_full  num edges: 47116\n",
      "adj_val   num edges: 5479\n",
      "adj_train num edges: 39381\n",
      "[WinError 183] 当文件已存在时，无法创建该文件。: 'E:/MDA-GCNFTG-main/gene_peco_data_/task_Tpe__testlabel0_1knn_edge_fold4/' E:/MDA-GCNFTG-main/gene_peco_data_/task_Tpe__testlabel0_1knn_edge_fold4/\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 47116/47116 [00:00<00:00, 736188.75it/s]\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "adj_full  num edges: 47116\n",
      "adj_val   num edges: 22602\n",
      "adj_train num edges: 21237\n",
      "--Complete-- 5\n",
      "# gene = 11177 | peco = 24\n",
      "# Test: gene = 2235 | peco = 4\n",
      "[WinError 183] 当文件已存在时，无法创建该文件。: 'E:/MDA-GCNFTG-main/gene_peco_data_/task_Tpe__testlabel0_3knn_edge_fold0/' E:/MDA-GCNFTG-main/gene_peco_data_/task_Tpe__testlabel0_3knn_edge_fold0/\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 141348/141348 [00:00<00:00, 781007.42it/s]\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "adj_full  num edges: 141348\n",
      "adj_val   num edges: 10242\n",
      "adj_train num edges: 115509\n",
      "[WinError 183] 当文件已存在时，无法创建该文件。: 'E:/MDA-GCNFTG-main/gene_peco_data_/task_Tpe__testlabel0_3knn_edge_fold1/' E:/MDA-GCNFTG-main/gene_peco_data_/task_Tpe__testlabel0_3knn_edge_fold1/\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 141348/141348 [00:00<00:00, 780837.69it/s]\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "adj_full  num edges: 141348\n",
      "adj_val   num edges: 6630\n",
      "adj_train num edges: 118508\n",
      "[WinError 183] 当文件已存在时，无法创建该文件。: 'E:/MDA-GCNFTG-main/gene_peco_data_/task_Tpe__testlabel0_3knn_edge_fold2/' E:/MDA-GCNFTG-main/gene_peco_data_/task_Tpe__testlabel0_3knn_edge_fold2/\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 141348/141348 [00:00<00:00, 803110.92it/s]\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "adj_full  num edges: 141348\n",
      "adj_val   num edges: 8068\n",
      "adj_train num edges: 117632\n",
      "[WinError 183] 当文件已存在时，无法创建该文件。: 'E:/MDA-GCNFTG-main/gene_peco_data_/task_Tpe__testlabel0_3knn_edge_fold3/' E:/MDA-GCNFTG-main/gene_peco_data_/task_Tpe__testlabel0_3knn_edge_fold3/\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 141348/141348 [00:00<00:00, 798491.09it/s]\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "adj_full  num edges: 141348\n",
      "adj_val   num edges: 11599\n",
      "adj_train num edges: 113665\n",
      "[WinError 183] 当文件已存在时，无法创建该文件。: 'E:/MDA-GCNFTG-main/gene_peco_data_/task_Tpe__testlabel0_3knn_edge_fold4/' E:/MDA-GCNFTG-main/gene_peco_data_/task_Tpe__testlabel0_3knn_edge_fold4/\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 141348/141348 [00:00<00:00, 780928.20it/s]\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "adj_full  num edges: 141348\n",
      "adj_val   num edges: 61376\n",
      "adj_train num edges: 56645\n",
      "--Complete-- 5\n",
      "# gene = 11177 | peco = 24\n",
      "# Test: gene = 2235 | peco = 4\n",
      "[WinError 183] 当文件已存在时，无法创建该文件。: 'E:/MDA-GCNFTG-main/gene_peco_data_/task_Tpe__testlabel0_5knn_edge_fold0/' E:/MDA-GCNFTG-main/gene_peco_data_/task_Tpe__testlabel0_5knn_edge_fold0/\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 235580/235580 [00:00<00:00, 832475.36it/s]\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "adj_full  num edges: 235580\n",
      "adj_val   num edges: 14078\n",
      "adj_train num edges: 189933\n",
      "[WinError 183] 当文件已存在时，无法创建该文件。: 'E:/MDA-GCNFTG-main/gene_peco_data_/task_Tpe__testlabel0_5knn_edge_fold1/' E:/MDA-GCNFTG-main/gene_peco_data_/task_Tpe__testlabel0_5knn_edge_fold1/\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 235580/235580 [00:00<00:00, 804027.35it/s]\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "adj_full  num edges: 235580\n",
      "adj_val   num edges: 8644\n",
      "adj_train num edges: 195725\n",
      "[WinError 183] 当文件已存在时，无法创建该文件。: 'E:/MDA-GCNFTG-main/gene_peco_data_/task_Tpe__testlabel0_5knn_edge_fold2/' E:/MDA-GCNFTG-main/gene_peco_data_/task_Tpe__testlabel0_5knn_edge_fold2/\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 235580/235580 [00:00<00:00, 815156.96it/s]\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "adj_full  num edges: 235580\n",
      "adj_val   num edges: 10770\n",
      "adj_train num edges: 193503\n",
      "[WinError 183] 当文件已存在时，无法创建该文件。: 'E:/MDA-GCNFTG-main/gene_peco_data_/task_Tpe__testlabel0_5knn_edge_fold3/' E:/MDA-GCNFTG-main/gene_peco_data_/task_Tpe__testlabel0_5knn_edge_fold3/\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 235580/235580 [00:00<00:00, 820843.23it/s]\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "adj_full  num edges: 235580\n",
      "adj_val   num edges: 15551\n",
      "adj_train num edges: 186347\n",
      "[WinError 183] 当文件已存在时，无法创建该文件。: 'E:/MDA-GCNFTG-main/gene_peco_data_/task_Tpe__testlabel0_5knn_edge_fold4/' E:/MDA-GCNFTG-main/gene_peco_data_/task_Tpe__testlabel0_5knn_edge_fold4/\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 235580/235580 [00:00<00:00, 862864.84it/s]\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "adj_full  num edges: 235580\n",
      "adj_val   num edges: 97041\n",
      "adj_train num edges: 87316\n",
      "--Complete-- 5\n",
      "# gene = 11177 | peco = 24\n",
      "# Test: gene = 2235 | peco = 4\n",
      "[WinError 183] 当文件已存在时，无法创建该文件。: 'E:/MDA-GCNFTG-main/gene_peco_data_/task_Tpe__testlabel0_7knn_edge_fold0/' E:/MDA-GCNFTG-main/gene_peco_data_/task_Tpe__testlabel0_7knn_edge_fold0/\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 329812/329812 [00:00<00:00, 832850.76it/s]\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "adj_full  num edges: 329812\n",
      "adj_val   num edges: 16890\n",
      "adj_train num edges: 262973\n",
      "[WinError 183] 当文件已存在时，无法创建该文件。: 'E:/MDA-GCNFTG-main/gene_peco_data_/task_Tpe__testlabel0_7knn_edge_fold1/' E:/MDA-GCNFTG-main/gene_peco_data_/task_Tpe__testlabel0_7knn_edge_fold1/\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 329812/329812 [00:00<00:00, 826597.63it/s]\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "adj_full  num edges: 329812\n",
      "adj_val   num edges: 10245\n",
      "adj_train num edges: 272185\n",
      "[WinError 183] 当文件已存在时，无法创建该文件。: 'E:/MDA-GCNFTG-main/gene_peco_data_/task_Tpe__testlabel0_7knn_edge_fold2/' E:/MDA-GCNFTG-main/gene_peco_data_/task_Tpe__testlabel0_7knn_edge_fold2/\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 329812/329812 [00:00<00:00, 831690.07it/s]\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "adj_full  num edges: 329812\n",
      "adj_val   num edges: 12630\n",
      "adj_train num edges: 268528\n",
      "[WinError 183] 当文件已存在时，无法创建该文件。: 'E:/MDA-GCNFTG-main/gene_peco_data_/task_Tpe__testlabel0_7knn_edge_fold3/' E:/MDA-GCNFTG-main/gene_peco_data_/task_Tpe__testlabel0_7knn_edge_fold3/\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 329812/329812 [00:00<00:00, 845629.69it/s]\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "adj_full  num edges: 329812\n",
      "adj_val   num edges: 18229\n",
      "adj_train num edges: 257038\n",
      "[WinError 183] 当文件已存在时，无法创建该文件。: 'E:/MDA-GCNFTG-main/gene_peco_data_/task_Tpe__testlabel0_7knn_edge_fold4/' E:/MDA-GCNFTG-main/gene_peco_data_/task_Tpe__testlabel0_7knn_edge_fold4/\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 329812/329812 [00:00<00:00, 877160.86it/s]\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "adj_full  num edges: 329812\n",
      "adj_val   num edges: 128194\n",
      "adj_train num edges: 114900\n",
      "--Complete-- 5\n",
      "# gene = 11177 | peco = 24\n",
      "# Test: gene = 2235 | peco = 4\n",
      "[WinError 183] 当文件已存在时，无法创建该文件。: 'E:/MDA-GCNFTG-main/gene_peco_data_/task_Tpe__testlabel0_10knn_edge_fold0/' E:/MDA-GCNFTG-main/gene_peco_data_/task_Tpe__testlabel0_10knn_edge_fold0/\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 471160/471160 [00:00<00:00, 841359.02it/s]\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "adj_full  num edges: 471160\n",
      "adj_val   num edges: 20574\n",
      "adj_train num edges: 372092\n",
      "[WinError 183] 当文件已存在时，无法创建该文件。: 'E:/MDA-GCNFTG-main/gene_peco_data_/task_Tpe__testlabel0_10knn_edge_fold1/' E:/MDA-GCNFTG-main/gene_peco_data_/task_Tpe__testlabel0_10knn_edge_fold1/\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 471160/471160 [00:00<00:00, 820859.25it/s]\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "adj_full  num edges: 471160\n",
      "adj_val   num edges: 12546\n",
      "adj_train num edges: 385748\n",
      "[WinError 183] 当文件已存在时，无法创建该文件。: 'E:/MDA-GCNFTG-main/gene_peco_data_/task_Tpe__testlabel0_10knn_edge_fold2/' E:/MDA-GCNFTG-main/gene_peco_data_/task_Tpe__testlabel0_10knn_edge_fold2/\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 471160/471160 [00:00<00:00, 835415.31it/s]\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "adj_full  num edges: 471160\n",
      "adj_val   num edges: 15223\n",
      "adj_train num edges: 379854\n",
      "[WinError 183] 当文件已存在时，无法创建该文件。: 'E:/MDA-GCNFTG-main/gene_peco_data_/task_Tpe__testlabel0_10knn_edge_fold3/' E:/MDA-GCNFTG-main/gene_peco_data_/task_Tpe__testlabel0_10knn_edge_fold3/\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 471160/471160 [00:00<00:00, 855366.49it/s]\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "adj_full  num edges: 471160\n",
      "adj_val   num edges: 21770\n",
      "adj_train num edges: 362722\n",
      "[WinError 183] 当文件已存在时，无法创建该文件。: 'E:/MDA-GCNFTG-main/gene_peco_data_/task_Tpe__testlabel0_10knn_edge_fold4/' E:/MDA-GCNFTG-main/gene_peco_data_/task_Tpe__testlabel0_10knn_edge_fold4/\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 471160/471160 [00:00<00:00, 889610.68it/s]\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "adj_full  num edges: 471160\n",
      "adj_val   num edges: 171680\n",
      "adj_train num edges: 154857\n",
      "--Complete-- 5\n",
      "# gene = 11177 | peco = 24\n",
      "# Test: gene = 2235 | peco = 4\n",
      "[WinError 183] 当文件已存在时，无法创建该文件。: 'E:/MDA-GCNFTG-main/gene_peco_data_/task_Tpe__testlabel0_15knn_edge_fold0/' E:/MDA-GCNFTG-main/gene_peco_data_/task_Tpe__testlabel0_15knn_edge_fold0/\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 706740/706740 [00:00<00:00, 843350.46it/s]\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "adj_full  num edges: 706740\n",
      "adj_val   num edges: 26100\n",
      "adj_train num edges: 552879\n",
      "[WinError 183] 当文件已存在时，无法创建该文件。: 'E:/MDA-GCNFTG-main/gene_peco_data_/task_Tpe__testlabel0_15knn_edge_fold1/' E:/MDA-GCNFTG-main/gene_peco_data_/task_Tpe__testlabel0_15knn_edge_fold1/\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 706740/706740 [00:00<00:00, 851509.22it/s]\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "adj_full  num edges: 706740\n",
      "adj_val   num edges: 16139\n",
      "adj_train num edges: 574414\n",
      "[WinError 183] 当文件已存在时，无法创建该文件。: 'E:/MDA-GCNFTG-main/gene_peco_data_/task_Tpe__testlabel0_15knn_edge_fold2/' E:/MDA-GCNFTG-main/gene_peco_data_/task_Tpe__testlabel0_15knn_edge_fold2/\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 706740/706740 [00:00<00:00, 848432.28it/s]\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "adj_full  num edges: 706740\n",
      "adj_val   num edges: 19081\n",
      "adj_train num edges: 565992\n",
      "[WinError 183] 当文件已存在时，无法创建该文件。: 'E:/MDA-GCNFTG-main/gene_peco_data_/task_Tpe__testlabel0_15knn_edge_fold3/' E:/MDA-GCNFTG-main/gene_peco_data_/task_Tpe__testlabel0_15knn_edge_fold3/\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 706740/706740 [00:00<00:00, 858721.70it/s]\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "adj_full  num edges: 706740\n",
      "adj_val   num edges: 27489\n",
      "adj_train num edges: 538241\n",
      "[WinError 183] 当文件已存在时，无法创建该文件。: 'E:/MDA-GCNFTG-main/gene_peco_data_/task_Tpe__testlabel0_15knn_edge_fold4/' E:/MDA-GCNFTG-main/gene_peco_data_/task_Tpe__testlabel0_15knn_edge_fold4/\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 706740/706740 [00:00<00:00, 910730.61it/s]\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "adj_full  num edges: 706740\n",
      "adj_val   num edges: 241882\n",
      "adj_train num edges: 219385\n",
      "--Complete-- 5\n"
     ]
    }
   ],
   "source": [
    "#for n_neigh in [1, 3, 5, 7, 15]:\n",
    "node_feature_label, num_node, node_feat, label, gene_ids, peco_ids, train_index_all, test_index_all, \\\n",
    "feats, role, class_map, adj_full, adj_train, adj_val, edge_src_dst = run(task = 'Tpe', isbalance = True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true,
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": [
    "# for n_neigh in [1, 3, 5, 7, 15]: \n",
    "node_feature_label, num_node, node_feat, label, gene_ids, peco_ids, train_index_all, test_index_all, \\\n",
    "feats, role, class_map, adj_full, adj_train, adj_val, edge_src_dst = run(task = 'Tg', isbalance = True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": [
    "# for n_neigh in [1, 3, 5, 7, 15]: \n",
    "node_feature_label, num_node, node_feat, label, gene_ids, peco_ids, train_index_all, test_index_all, \\\n",
    "feats, role, class_map, adj_full, adj_train, adj_val, edge_src_dst = run(task = 'Tp', isbalance = True)"
   ]
  }
 ],
 "metadata": {
  "anaconda-cloud": {},
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
